//
//  ScreenTableViewCell.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/8/21.
//

#import "ScreenTableViewCell.h"
#import "YTBaseSelectStringView.h"

@interface ScreenStringTableViewCell ()

@property (nonatomic ,strong) UILabel * nameLab;
@property (nonatomic ,strong) YTMinSelectStringView * contentview;

@end

@implementation ScreenStringTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    self.contentView.clipsToBounds = YES;
    MJWeakSelf
    
    UILabel * nameLab = [DTKTool labelWithText:@"-" andFont:kCFont(17) andTextColor:KcolorHex(@"#242729")];
    self.nameLab = nameLab;
    [self.contentView addSubview:nameLab];
    [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.top.offset(kwt(19));
    }];
    
    YTMinSelectStringView * contentview = [YTMinSelectStringView NewViewWithLeft];
    self.contentview = contentview;
    contentview.font = kFont(16);
    contentview.backgroundColor = KcolorHex(@"#F2F4F6");
    [self.contentView addSubview:contentview];
    [contentview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.top.offset(kwt(48));
        make.right.offset(kwt(-15));
        make.height.offset(kwt(40));
    }];
    
}
- (void)setName:(NSString *)name andContent:(NSString *)content andBlock:(void(^)(NSString * content))block {
    self.nameLab.text = name;
    self.contentview.content = content;
    self.contentview.block = block;
}
@end

@interface ScreenTimeTableViewCell ()

@property (nonatomic ,strong) NSString * StartTime;
@property (nonatomic ,strong) NSString * EndTime;
@property (nonatomic ,strong) UILabel * nameLab;
@property (nonatomic ,strong) UILabel * leftLab;
@property (nonatomic ,strong) UILabel * rightLab;
@property (nonatomic ,strong) void(^block)(NSString * startTime,NSString * endTime);

@end

@implementation ScreenTimeTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    self.contentView.clipsToBounds = YES;
    MJWeakSelf
    
    UILabel * nameLab = [DTKTool labelWithText:@"-" andFont:kCFont(17) andTextColor:KcolorHex(@"#242729")];
    self.nameLab = nameLab;
    [self.contentView addSubview:nameLab];
    [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.top.offset(kwt(19));
    }];
    
    
    UIView * leftview = [UIView new];
    leftview.addClickBlock(^{
       [weakSelf StartTimeClick] ;
    });
    
    leftview.backgroundColor = KcolorHex(@"#F2F4F6");
    [DTKTool YJBK:kwt(5) andView:leftview andWidth:0.5 andColor:KcolorHex(@"#ECECEC")];
    [self.contentView addSubview:leftview];
    [leftview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.top.offset(kwt(48));
        make.width.offset(kwt(156));
        make.height.offset(kwt(40));
    }];
    
    UILabel * leftLab = [DTKTool labelWithText:@"-" andFont:kFont(16) andTextColor:KcolorHex(@"#242729")];
    self.leftLab = leftLab;
    [leftview addSubview:leftLab];
    [leftLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(12));
        make.right.offset(kwt(-12));
        make.centerY.offset(0);
    }];
    
    UIView * lineview = [UIView new];
    lineview.backgroundColor = KcolorHex(@"#BABABA");
    [self.contentView addSubview:lineview];
    [lineview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(15));
        make.height.offset(kwt(2));
        make.centerX.offset(0);
        make.centerY.equalTo(leftview);
    }];
    
    
    UIView * rightview = [UIView new];
    rightview.addClickBlock(^{
       [weakSelf EndTimeClick] ;
    });
    rightview.backgroundColor = KcolorHex(@"#F2F4F6");
    [DTKTool YJBK:kwt(5) andView:rightview andWidth:0.5 andColor:KcolorHex(@"#ECECEC")];
    [self.contentView addSubview:rightview];
    [rightview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(kwt(-15));
        make.top.offset(kwt(48));
        make.width.offset(kwt(156));
        make.height.offset(kwt(40));
    }];
    
    UILabel * rightLab = [DTKTool labelWithText:@"-" andFont:kFont(16) andTextColor:KcolorHex(@"#242729")];
    self.rightLab = rightLab;
    [rightview addSubview:rightLab];
    [rightLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(12));
        make.right.offset(kwt(-12));
        make.centerY.offset(0);
    }];
    
    
}
- (void)setName:(NSString *)name andStartTime:(NSString *)StartTime andEndTime:(NSString *)EndTime andBlock:(void(^)(NSString * StartTime,NSString *EndTime))block{
    self.nameLab.text = name;
    self.StartTime = StartTime;
    self.EndTime = EndTime;
    if(StartTime.length == 0){
        self.leftLab.text = @"开始时间";
        self.leftLab.textColor = KcolorHex(@"#787878");
    } else {
        self.leftLab.text = StartTime;
        self.leftLab.textColor = KcolorHex(@"#242729");
    }
    if(EndTime.length == 0){
        self.rightLab.text = @"结束时间";
        self.rightLab.textColor = KcolorHex(@"#787878");
    } else {
        self.rightLab.text = EndTime;
        self.rightLab.textColor = KcolorHex(@"#242729");
    }
    self.block = block;
}


- (void)StartTimeClick{
    if(self.block){
        self.block(self.StartTime, self.EndTime);
    }
}
- (void)EndTimeClick{
    if(self.block){
        self.block(self.StartTime, self.EndTime);
    }
}


@end

@interface ScreenDXTableViewCell ()

@property (nonatomic ,strong) UILabel * nameLab;
@property (nonatomic ,strong) UIView * btnview;
@property (nonatomic ,strong) UIButton * qbbtn;
@property (nonatomic ,strong) UIButton * dxpbtn;
@property (nonatomic ,strong) UIButton * ytybtn;
@property (nonatomic ,strong) UIButton * yjjbtn;
@property (nonatomic ,strong) UIButton * ycxbtn;
@property (nonatomic ,strong) UIButton * seledbtn;
@property (nonatomic ,strong) void(^block)(int state);
@end

@implementation ScreenDXTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    self.contentView.clipsToBounds = YES;
    MJWeakSelf
    
    UILabel * nameLab = [DTKTool labelWithText:@"-" andFont:kCFont(17) andTextColor:KcolorHex(@"#242729")];
    self.nameLab = nameLab;
    [self.contentView addSubview:nameLab];
    [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(15));
        make.top.offset(kwt(19));
    }];
    ///处理状态 1 待审批 2 已同意 3 已拒绝 4 已撤销
    
    UIView * btnview = [UIView new];
    self.btnview = btnview;
    [self.contentView addSubview:btnview];
    [btnview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.top.offset(kwt(50));
    }];
    
    UIButton * qbbtn = [UIButton buttonWithType:0];
    self.qbbtn = qbbtn;
    [qbbtn setTitle:@"全部" forState:UIControlStateNormal];
    [qbbtn setTitleColor:KcolorHex(@"#242729") forState:UIControlStateNormal];
    [qbbtn setTitleColor:KcolorHex(@"#0669FE") forState:UIControlStateSelected];
    qbbtn.titleLabel.font = kFont(16);
    qbbtn.backgroundColor = KcolorHex(@"#F2F4F6");
    [qbbtn addTarget:self action:@selector(btnClickWithBtn:) forControlEvents:UIControlEventTouchUpInside];
    [DTKTool YJBK:kwt(5) andView:qbbtn andWidth:0.5 andColor:KcolorHex(@"#ECECEC")];
    [btnview addSubview:qbbtn];
    [qbbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.left.offset(kwt(15));
        make.width.offset(kwt(103));
        make.height.offset(kwt(40));
    }];
    
   
    UIButton * dxpbtn = [UIButton buttonWithType:0];
    self.dxpbtn = dxpbtn;
    [dxpbtn setTitle:@"取消" forState:UIControlStateNormal];
    [dxpbtn setTitleColor:KcolorHex(@"#242729") forState:UIControlStateNormal];
    [dxpbtn setTitleColor:KcolorHex(@"#0669FE") forState:UIControlStateSelected];
    dxpbtn.titleLabel.font = kFont(16);
    dxpbtn.backgroundColor = KcolorHex(@"#F2F4F6");
    [dxpbtn addTarget:self action:@selector(btnClickWithBtn:) forControlEvents:UIControlEventTouchUpInside];
    [DTKTool YJBK:kwt(5) andView:dxpbtn andWidth:0.5 andColor:KcolorHex(@"#ECECEC")];
    [btnview addSubview:dxpbtn];
    [dxpbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.centerX.offset(0);
        make.width.offset(kwt(103));
        make.height.offset(kwt(40));
    }];
    
    
    UIButton * ytybtn = [UIButton buttonWithType:0];
    self.ytybtn = ytybtn;
    [ytybtn setTitle:@"转交" forState:UIControlStateNormal];
    [ytybtn setTitleColor:KcolorHex(@"#242729") forState:UIControlStateNormal];
    [ytybtn setTitleColor:KcolorHex(@"#0669FE") forState:UIControlStateSelected];
    ytybtn.titleLabel.font = kFont(16);
    ytybtn.backgroundColor = KcolorHex(@"#F2F4F6");
    [ytybtn addTarget:self action:@selector(btnClickWithBtn:) forControlEvents:UIControlEventTouchUpInside];
    [DTKTool YJBK:kwt(5) andView:ytybtn andWidth:0.5 andColor:KcolorHex(@"#ECECEC")];
    [btnview addSubview:ytybtn];
    [ytybtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.right.offset(kwt(-15));
        make.width.offset(kwt(103));
        make.height.offset(kwt(40));
    }];
    
}


- (void)btnClickWithBtn:(UIButton *)btn{
    if(self.seledbtn == btn){
        return;
    }
    self.seledbtn.selected = NO;
    self.seledbtn.titleLabel.font = kFont(16);
    self.seledbtn.backgroundColor = KcolorHex(@"#F2F4F6");
    [DTKTool YJBK:kwt(5) andView:self.seledbtn andWidth:0.5 andColor:KcolorHex(@"#ECECEC")];
    self.seledbtn = btn;
    self.seledbtn.selected = YES;
    self.seledbtn.titleLabel.font = kCFont(16);
    self.seledbtn.backgroundColor = KcolorHex(@"#EDF4FF");
    [DTKTool YJBK:kwt(5) andView:self.seledbtn andWidth:0.5 andColor:KcolorHex(@"#0669FE")];
    if(self.block){
        if(self.qbbtn == btn){
            self.block(0);
        } else if(self.dxpbtn == btn){
            self.block(1);
        } else if(self.ytybtn == btn){
            self.block(2);
        } else if(self.yjjbtn == btn){
            self.block(3);
        } else if(self.ycxbtn == btn){
            self.block(4);
        }
    }
  
    
}
- (void)setName:(NSString *)name andState:(int)state andBlock:(void(^)(int state))block{
    self.nameLab.text = name;
   
    self.block = block;
    
    ///处理状态 1 待审批 2 已同意 3 已拒绝 4 已撤销
    if(state == 0){
        [self btnClickWithBtn:self.qbbtn];
    } else  if(state == 1){
        [self btnClickWithBtn:self.dxpbtn];
    } else  if(state == 2){
        [self btnClickWithBtn:self.ytybtn];
    } else  if(state == 3){
        [self btnClickWithBtn:self.yjjbtn];
    } else  if(state == 4){
        [self btnClickWithBtn:self.ycxbtn];
    }
    
}
@end
